<!-- 网站信息 -->
<template>
    <div class="website-information">
        <el-form ref="formRef" :rules="formRules" class="ls-form" :model="formData" label-width="120px">
            <el-card shadow="never" class="!border-none">
                <div class="text-xl font-medium mb-[20px]">企查查配置</div>
              <el-form-item label="AppID" prop="appKey">
                  <div class="w-80">
                      <el-input v-model="formData.appKey" placeholder="请输入appKey" />
                  </div>
              </el-form-item>
              <el-form-item label="AppSecret" prop="secretKey">
                  <div class="w-80">
                      <el-input v-model="formData.secretKey" placeholder="请输入secretKey" />
                  </div>
              </el-form-item>
				</el-card>
        </el-form>
        <footer-btns>
            <el-button type="primary" @click="handleSubmit">保存</el-button>
        </footer-btns>
    </div>
</template>

<script lang="ts" setup name="webInformation">
import { info,set } from '@/api/setting/qcc_set'
import type { FormInstance } from 'element-plus'
const formRef = ref<FormInstance>()

// 表单数据
const formData = reactive({
    appKey: '', // 合同
    secretKey: '', // 身份证
})

const formRules = {
    appKey: [
        {
            required: true,
            message: '请输入appKey',
            trigger: ['blur', 'change']
        }
    ],
    secretKey: [
        {
            required: true,
            message: '请输入secretKey',
            trigger: ['blur', 'change']
        }
    ]
}

// 获取展示数据
const getData = async () => {
    const data = await info()
	for (const key in formData) {
	    //@ts-ignore
	    formData[key] = data[key]
	}
}


// 提交保存
const handleSubmit = async () => {
    await set(formData)
    getData()
}

getData()
</script>

<style lang="scss" scoped></style>
